<template>
  <div>
    <h3>默认展示</h3>
    <span>{{name}}</span>

    <h3>示例一、定义一个局部过滤器</h3>
    <span>{{name | capitalize}} {{name}}</span>

    <h3>示例二、过滤器串联</h3>
    <span>{{name | capitalize | trim}}</span>

  </div>
</template>

<script>
export default {
  data () {
    return {

      name: 'asen    ',
      age: 20,


    }
  },


  filters: {

    capitalize (value) {
      if (!value) return ''
      value = value.toString()
      return value.charAt(0).toUpperCase() + value.slice(1)

    },
    trim (value) {
      console.log(value)
      return value.replace(/^\s+|\s+$/g, "")


    }


  }
}
</script>


<style scoped>
</style>